const fse = require('fs-extra');
const path = require('path');

const dirname = process.cwd()
const copyFiles = [
  'pages',
  'api',
  'index.tsx',
  'routes.ts',
  'utils/auth.ts',
  'utils/env.ts',
  'utils/request.ts',
  'utils/navigate.ts',
]
module.exports = () => {
    if(!fse.existsSync(path.resolve('./public/index.html'))){
        fse.copySync(path.resolve(__dirname,'../template/index.html'),path.resolve(dirname,'./public/index.html'))
    }
    copyFiles.forEach(key=>{
        if(!fse.existsSync(path.resolve(dirname, key))){
          console.log('copt from:',path.resolve(__dirname,'../template',key))
          console.log('copt to:',path.resolve(dirname,'src',key))
          fse.copySync(path.resolve(__dirname,'../template',key),path.resolve(dirname,'src',key))
        }      
    })
};
